package com.example.waternetwork.api.supervision.controller;

import com.example.waternetwork.api.model.R;
import com.example.waternetwork.api.supervision.entity.BaseReservoir;
import com.example.waternetwork.api.supervision.service.IBaseReservoirService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 水库基础信息表 前端控制器
 * </p>
 *
 * @author auto gen
 * @since 2025-06-30
 */
@RestController
@RequestMapping("/supervision/baseReservoir")
@Tag(name = "水库基础信息管理", description = "提供根据水库编码查询水库基础信息等功能")
public class BaseReservoirController {

    @Autowired
    private IBaseReservoirService baseReservoirService;

    @GetMapping("/getResInfoByCode")
    @Operation(
        summary = "根据水库编码获取水库基础信息",
        description = "通过提供的水库编码，查询并返回对应的水库基础信息数据。",
        responses = {
            @ApiResponse(responseCode = "200", description = "成功获取水库基础信息", content = @Content(schema = @Schema(implementation = R.class))),
            @ApiResponse(responseCode = "400", description = "参数为空")
        }
    )
    R<BaseReservoir> getResInfoByCode(@Parameter(description = "水库唯一编码，用于查询对应的水库信息", required = true) @RequestParam("code") String code) {
        if (StringUtils.isEmpty(code)) {
            return R.fail("参数不能为空");
        }
        return R.ok(baseReservoirService.getResInfoByCode(code));
    }

}
